package com.csw.shuanfa.CodeImprove.redlockThread.locktest.service;

import com.csw.shuanfa.CodeImprove.redlockThread.locktest.service.impl.DateBaseComponentImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class SingleService {
    @Autowired
    private DateBaseComponentImpl dateBaseComponentImpl;

    public void oversold(int reqNums) {
        try {
            for (int i = 0; i < reqNums; i++) {
                // 一个线程模拟一个请求
                new Thread(() -> {
                    dateBaseComponentImpl.decrment();
                }).start();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

    }


}
